home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / vbhelp.exe / HELPF.FRM < prev    next >
Encoding:
Text File  |  1993-02-09  |  24.4 KB  |  698 lines

  1. Version 1.00
  2. BEGIN Form frmHelpMain
  3.     AutoRedraw   = -1
  4.     BackColor    = QBColor(7)
  5.     BorderStyle  = 2
  6.     Caption      = "Help"
  7.     ControlBox   = -1
  8.     Enabled      = -1
  9.     ForeColor    = QBColor(0)
  10.     Height       = Char(19)
  11.     Left         = Char(7)
  12.     MaxButton    = -1
  13.     MinButton    = -1
  14.     MousePointer = 0
  15.     Tag          = ""
  16.     Top          = Char(2)
  17.     Visible      = -1
  18.     Width        = Char(66)
  19.     WindowState  = 0
  20.     BEGIN HScrollBar hscHelp
  21.         Attached     = -1
  22.         DragMode     = 0
  23.         Enabled      = -1
  24.         Height       = Char(1)
  25.         LargeChange  = 20
  26.         Left         = Char(8)
  27.         Max          = 32767
  28.         Min          = 1
  29.         MousePointer = 0
  30.         SmallChange  = 1
  31.         TabIndex     = 6
  32.         TabStop      = 0
  33.         Tag          = ""
  34.         Top          = Char(20)
  35.         Value        = 1
  36.         Visible      = -1
  37.         Width        = Char(63)
  38.     END
  39.     BEGIN VScrollBar vscHelp
  40.         Attached     = -1
  41.         DragMode     = 0
  42.         Enabled      = -1
  43.         Height       = Char(16)
  44.         LargeChange  = 1
  45.         Left         = Char(72)
  46.         Max          = 32767
  47.         Min          = 1
  48.         MousePointer = 0
  49.         SmallChange  = 1
  50.         TabIndex     = 7
  51.         TabStop      = 0
  52.         Tag          = ""
  53.         Top          = Char(3)
  54.         Value        = 1
  55.         Visible      = -1
  56.         Width        = Char(1)
  57.     END
  58.     BEGIN PictureBox pctBackground
  59.         AutoRedraw   = -1
  60.         BackColor    = QBColor(7)
  61.         BorderStyle  = 0
  62.         DragMode     = 0
  63.         Enabled      = -1
  64.         ForeColor    = QBColor(0)
  65.         Height       = Char(14)
  66.         Left         = Char(0)
  67.         MousePointer = 0
  68.         TabIndex     = 0
  69.         TabStop      = -1
  70.         Tag          = ""
  71.         Top          = Char(3)
  72.         Visible      = -1
  73.         Width        = Char(64)
  74.     END
  75.     BEGIN CommandButton cmdButtonBar
  76.         BackColor    = QBColor(7)
  77.         Cancel       = 0
  78.         Caption      = "&Contents"
  79.         Default      = 0
  80.         DragMode     = 0
  81.         Enabled      = 0
  82.         Height       = Char(3)
  83.         Index        = 0
  84.         Left         = Char(0)
  85.         MousePointer = 0
  86.         TabIndex     = 1
  87.         TabStop      = 0
  88.         Tag          = ""
  89.         Top          = Char(0)
  90.         Visible      = -1
  91.         Width        = Char(12)
  92.     END
  93.     BEGIN CommandButton cmdButtonBar
  94.         BackColor    = QBColor(7)
  95.         Cancel       = 0
  96.         Caption      = "&Search..."
  97.         Default      = 0
  98.         DragMode     = 0
  99.         Enabled      = 0
  100.         Height       = Char(3)
  101.         Index        = 1
  102.         Left         = Char(13)
  103.         MousePointer = 0
  104.         TabIndex     = 2
  105.         TabStop      = 0
  106.         Tag          = ""
  107.         Top          = Char(0)
  108.         Visible      = -1
  109.         Width        = Char(12)
  110.     END
  111.     BEGIN CommandButton cmdButtonBar
  112.         BackColor    = QBColor(7)
  113.         Cancel       = 0
  114.         Caption      = "&Back"
  115.         Default      = 0
  116.         DragMode     = 0
  117.         Enabled      = 0
  118.         Height       = Char(3)
  119.         Index        = 2
  120.         Left         = Char(26)
  121.         MousePointer = 0
  122.         TabIndex     = 3
  123.         TabStop      = 0
  124.         Tag          = ""
  125.         Top          = Char(0)
  126.         Visible      = -1
  127.         Width        = Char(12)
  128.     END
  129.     BEGIN CommandButton cmdButtonBar
  130.         BackColor    = QBColor(7)
  131.         Cancel       = 0
  132.         Caption      = "His&tory..."
  133.         Default      = 0
  134.         DragMode     = 0
  135.         Enabled      = 0
  136.         Height       = Char(3)
  137.         Index        = 3
  138.         Left         = Char(39)
  139.         MousePointer = 0
  140.         TabIndex     = 4
  141.         TabStop      = 0
  142.         Tag          = ""
  143.         Top          = Char(0)
  144.         Visible      = -1
  145.         Width        = Char(12)
  146.     END
  147.     BEGIN CommandButton cmdButtonBar
  148.         BackColor    = QBColor(7)
  149.         Cancel       = 0
  150.         Caption      = "Co&py..."
  151.         Default      = 0
  152.         DragMode     = 0
  153.         Enabled      = -1
  154.         Height       = Char(3)
  155.         Index        = 4
  156.         Left         = Char(52)
  157.         MousePointer = 0
  158.         TabIndex     = 5
  159.         TabStop      = 0
  160.         Tag          = ""
  161.         Top          = Char(0)
  162.         Visible      = -1
  163.         Width        = Char(12)
  164.     END
  165. END
  166. ' ------------------------------------------------------------------------
  167. ' Visual Basic for MS-DOS Help Toolkit
  168. '
  169. ' Help Window Form
  170. '
  171. ' The Help Toolkit (HELP.BAS, HELPF.FRM, and HELPUTIL.FRM)
  172. ' makes it easy to add a hypertext Help system to your
  173. ' applications.
  174. '
  175. ' To use the Help Toolkit in your programs, include
  176. ' HELP.BAS, HELPF.FRM, and HELPUTIL.FRM in your program or
  177. ' use the supplied library (HELP.LIB, HELPA.LIB - AltMath
  178. ' version) and Quick library (HELP.QLB) and call the
  179. ' appropriate routines to load and display your help topics.
  180. ' Forms and code modules that call Help routines
  181. ' must include HELP.BI ('$INCLUDE: 'HELP.BI').'
  182. '
  183. ' Refer to the module level comments in HELP.BAS for
  184. ' more information on using the Help Toolkit.
  185. '
  186. ' Copyright (C) 1982-1992 Microsoft Corporation
  187. '
  188. ' You have a royalty-free right to use, modify, reproduce
  189. ' and distribute the sample applications and toolkits provided with
  190. ' Visual Basic for MS-DOS (and/or any modified version)
  191. ' in any way you find useful, provided that you agree that
  192. ' Microsoft has no warranty, obligations or liability for
  193. ' any of the sample applications or toolkits.
  194. ' ------------------------------------------------------------------------
  195.  
  196. ' Include file containing procedure declarations.
  197. '$INCLUDE: 'HELP.BI'
  198.  
  199. '$FORM frmHelpUtils         ' Form for Search, History, and Change dialogs
  200.  
  201. TYPE IndexType              ' Used to index Help topics
  202.     StartFilePtr AS LONG    ' Position within the topic's file
  203.     NumLines AS INTEGER     ' Number of lines in the Help topic
  204. END TYPE
  205.  
  206. TYPE PointType
  207.     X AS INTEGER            ' Horizontal location
  208.     Y AS INTEGER            ' Vertical location
  209. END TYPE
  210.  
  211. ' Variables common to HELP.BAS, HELPF.FRM, and HELPUTIL.FRM.
  212. COMMON SHARED /HelpLib/ DialogBackcolor AS INTEGER ' Background color for Help dialog boxes (Search, Copy, History)
  213. COMMON SHARED /HelpLib/ DialogForecolor AS INTEGER ' Foreground color for Help dialog boxes (Search, Copy, History)
  214.  
  215. ' Variables common to HELP.BAS and HELPF.FRM.
  216. COMMON SHARED /HelpLib/ Topic() AS STRING ' Lines of the current Help topic
  217. COMMON SHARED /HelpLib/ LeftChar AS INTEGER ' Leftmost character of the Help topic given the horizonal scroll position
  218. COMMON SHARED /HelpLib/ StartLine AS INTEGER ' Top line of the Help topic given the vertical scroll position
  219. COMMON SHARED /HelpLib/ MaxLineLen AS INTEGER ' Longest line of the Help topic
  220. COMMON SHARED /HelpLib/ HelpIndexPtr() AS IndexType ' Table that stores data about each Help topic
  221. COMMON SHARED /HelpLib/ HelpIndexTopics() AS STRING ' Array of Help topic names.  Used with the HelpIndexPtr table.
  222. COMMON SHARED /HelpLib/ HelpFileNum AS INTEGER ' Logical file number assigned to the Help file by HelpRegister
  223. COMMON SHARED /HelpLib/ HelpTopicStack()  AS STRING ' Array of the last 20 Help topics shown
  224. COMMON SHARED /HelpLib/ HelpTopicStackPtr  AS INTEGER ' Number of topics in the HelpTopicStack
  225. COMMON SHARED /HelpLib/ TopicFound AS STRING ' The Help topic being shown
  226. COMMON SHARED /HelpLib/ MaxHistoryStack AS INTEGER ' Maximum allowed size of the HelpTopicStack.  HelpRegister sets to 20.
  227. COMMON SHARED /HelpLib/ UnloadOnClose AS INTEGER ' Flag that determines if closing the Help form terminates the Help system.
  228. COMMON SHARED /HelpLib/ KillHelp AS INTEGER ' Flag that HelpClose sets to terminate the Help form
  229. COMMON SHARED /HelpLib/ CursorPos AS PointType ' Position of the currently selected Help link within a topic
  230. COMMON SHARED /HelpLib/ ButtonBarHeight AS INTEGER ' Number of lines to reserve at the top of the form for the button bar.  0 or 3.
  231. COMMON SHARED /HelpLib/ CloseOnEscape AS INTEGER ' If TRUE, pressing ESC will close the Help window
  232.  
  233. DEFINT A-Z
  234.  
  235. CONST StartChar = ""
  236. CONST EndChar = ""
  237. CONST FALSE = 0
  238. CONST TRUE = NOT FALSE
  239.  
  240. '  Click event procedure for the button bar command buttons (control array)..
  241. '  Invokes appropriate action when user clicks one of the buttons.
  242. SUB cmdButtonBar_Click (index AS INTEGER)
  243.     SELECT CASE index
  244.         CASE 0 ' Contents button
  245.             pctBackground.SETFOCUS
  246.             HelpShowTopic "Contents"
  247.         CASE 1 ' Search button
  248.             HelpSearch
  249.         CASE 2 ' Back button
  250.             HelpTopicStackPtr = HelpTopicStackPtr - 2
  251.             pctBackground.SETFOCUS
  252.             HelpShowTopic HelpTopicStack(HelpTopicStackPtr + 1)
  253.         CASE 3 ' History button
  254.             FOR i = HelpTopicStackPtr TO 1 STEP -1
  255.                 frmHelpUtils.lstHistory.ADDITEM HelpTopicStack(i)
  256.             NEXT i
  257.             frmHelpUtils.Caption = "History"
  258.             frmHelpUtils.lstHistory.ListIndex = 1
  259.             frmHelpUtils.lstHistory.Visible = TRUE
  260.             frmHelpUtils.lstSearch.Visible = FALSE
  261.             frmHelpUtils.SHOW 1
  262.             RequestedTopic$ = frmHelpUtils.Tag
  263.             UNLOAD frmHelpUtils
  264.             pctBackground.SETFOCUS
  265.  
  266.             ' RequestedTopic will be null if CANCEL was
  267.             ' pressed.
  268.             IF RequestedTopic$ <> "" THEN
  269.                 HelpShowTopic RequestedTopic$
  270.             END IF
  271.         CASE 4 ' Copy button
  272.             frmHelpUtils.Width = 63
  273.             frmHelpUtils.Caption = "Copy"
  274.             frmHelpUtils.txtCopyArea.Visible = TRUE
  275.             frmHelpUtils.lstHistory.Visible = FALSE
  276.             frmHelpUtils.lstSearch.Visible = FALSE
  277.             frmHelpUtils.cmdOK.Caption = "Copy"
  278.             frmHelpUtils.cmdOK.Left = frmHelpUtils.cmdOK.Left + 8
  279.             frmHelpUtils.cmdCancel.Left = frmHelpUtils.cmdOK.Left
  280.             frmHelpUtils.lblSelectTopic.Visible = FALSE
  281.             frmHelpUtils.lblSelectText.Visible = TRUE
  282.             frmHelpUtils.Left = (screen.Width - Width) \ 2
  283.             frmHelpUtils.Top = (screen.Height - Height) \ 2
  284.  
  285.             ' Fill txtCopyArea with the contents of the
  286.             ' current topic.
  287.             ' Use temp$ instead of txtCopyArea itself
  288.             ' for speed reasons.
  289.             '
  290.             temp$ = ""
  291.             FOR i = 1 TO UBOUND(Topic)
  292.                 temp$ = temp$ + Topic(i) + CHR$(13)
  293.             NEXT i
  294.             frmHelpUtils.txtCopyArea.text = temp$
  295.  
  296.             frmHelpUtils.SHOW 1
  297.             UNLOAD frmHelpUtils
  298.             pctBackground.SETFOCUS
  299.     END SELECT
  300. END SUB
  301.  
  302. ' Load event procedure for the form.
  303. ' Sets default values and centers the form.
  304. '
  305. SUB Form_Load ()
  306.     REDIM PRESERVE Topic(1 TO 50)  AS STRING
  307.     StartLine = 1
  308.     LeftChar = 1
  309.     hscHelp.Value = 1
  310.     vscHelp.Value = 1
  311.  
  312.     ' Center the form.
  313.     Left = (screen.Width - Width) \ 2
  314.     Top = (screen.Height - Height) \ 2
  315. END SUB
  316.  
  317. ' Resize event procedure for the form.
  318. ' Ensures pctBackground is always the correct size
  319. ' and that various scroll bar settings are correct
  320. ' for the new form size.
  321. '
  322. SUB Form_Resize ()
  323.     IF ScaleHeight > 3 THEN
  324.         pctBackground.MOVE 0, ButtonBarHeight, ScaleWidth, ScaleHeight - ButtonBarHeight
  325.         vscHelp.LargeChange = ScaleHeight - ButtonBarHeight
  326.         hscHelp.Max = HelpMax(MaxLineLen - pctBackground.ScaleWidth + 1, 1)
  327.         vscHelp.Max = HelpMax(UBOUND(Topic) - pctBackground.ScaleHeight + 1, 1)
  328.     END IF
  329.     HelpPrintText StartLine, LeftChar
  330.     pctBackground.SETFOCUS
  331. END SUB
  332.  
  333. ' Unload event procedure for the form.
  334. ' Cancels the form close unless UnloadOnClose
  335. ' flag is set to TRUE in the HelpSetOptions routine.
  336. '
  337. SUB Form_Unload (Cancel AS INTEGER)
  338.     IF UnloadOnClose OR KillHelp THEN
  339.         CLOSE HelpFileNum
  340.         HelpFileNum = 0
  341.     ELSE
  342.         ' KillHelp is FALSE unless HelpClose sets it to
  343.         ' TRUE
  344.         IF KillHelp = FALSE THEN
  345.             Cancel = TRUE
  346.             HIDE
  347.         ELSE
  348.             CLOSE HelpFileNum
  349.         END IF
  350.     END IF
  351. END SUB
  352.  
  353. ' Change event procedure for the horizontal scroll bar.
  354. ' Scrolls help topic text.
  355. SUB hscHelp_Change ()
  356.     ' Call the HelpPrintText routine using the new
  357.     ' horizontal scroll bar value.
  358.     HelpPrintText StartLine, (hscHelp.Value)
  359.  
  360.     ' Refresh the form and ensure pctBackground
  361.     ' has the focus.
  362.     pctBackground.REFRESH
  363.     pctBackground.SETFOCUS
  364. END SUB
  365.  
  366. ' KeyPress event procedure for the pctBackground.
  367. ' No other control needs a KeyPress routine because
  368. ' other Help rountines were written to ensure that
  369. ' pctBackground always has the focus.
  370. '
  371. ' See KeyUp event procedure for cursor navigation
  372. ' and Tab key handlers.
  373. '
  374. SUB pctBackground_KeyPress (KeyAscii AS INTEGER)
  375.     SELECT CASE KeyAscii
  376.         CASE 13 ' ENTER key
  377.             ' Jump to a link if if TAB or Shift-TAB have
  378.             ' been used to select one.
  379.             IF TopicFound <> "" THEN
  380.                 HelpShowTopic TopicFound
  381.             END IF
  382.         CASE 27 'ESC key
  383.             ' Close the Help form is ESC is pressed
  384.             ' and the CloseOnEscape flag was set
  385.             ' by HelpSetOptions
  386.             IF CloseOnEscape THEN
  387.                 IF UnloadOnClose THEN
  388.                     HelpClose
  389.                 ELSE
  390.                     Form_Unload Cancel
  391.                 END IF
  392.             END IF
  393.  
  394.         ' The following statements click the appropriate
  395.         ' command button as if the mouse was used.
  396.         '
  397.         CASE 67, 99     'C as in Contents
  398.             IF cmdButtonBar(0).Visible AND cmdButtonBar(0).Enabled THEN cmdButtonBar_Click 0
  399.         CASE 83, 115    'S as in Search
  400.             IF cmdButtonBar(1).Visible AND cmdButtonBar(1).Enabled THEN cmdButtonBar_Click 1
  401.         CASE 66, 98     'B as in Back
  402.             IF cmdButtonBar(2).Visible AND cmdButtonBar(2).Enabled THEN cmdButtonBar_Click 2
  403.         CASE 84, 116    'T as in hisTory
  404.             IF cmdButtonBar(3).Visible AND cmdButtonBar(3).Enabled THEN cmdButtonBar_Click 3
  405.         CASE 80, 112    'P as in coPy
  406.             IF cmdButtonBar(4).Visible AND cmdButtonBar(4).Enabled THEN cmdButtonBar_Click 4
  407.     END SELECT
  408. END SUB
  409.  
  410. ' KeyUp event procedure for keyboard navigation.
  411. ' No other control needs a KeyUp routine because other
  412. ' Help rountines were written to ensure that
  413. ' pctBackground always has the focus.
  414. '
  415. ' See KeyPress for ENTER, ESCAPE, C, S, B,
  416. ' T, and P handlers.
  417. '
  418. SUB pctBackground_KeyUp (KeyCode AS INTEGER, Shift AS INTEGER)
  419.     SELECT CASE KeyCode
  420.         CASE 9 ' tab key
  421.             IF (Shift AND 1) = 0 THEN
  422.                 ' Search forward.  Shift is not
  423.                 ' pressed.
  424.                 Direction = 1
  425.             ELSE
  426.                 ' Search backwards.  Shift is
  427.                 ' pressed.
  428.                 Direction = -1
  429.             END IF
  430.  
  431.             ' CursorPos.Y is only 0 if no link has
  432.             ' been highlighted yet.
  433.             IF CursorPos.Y = 0 THEN
  434.                 ' No link is currently selected.
  435.                 ' Find the first link in the topic.
  436.  
  437.                 MaxTopicLines = UBOUND(Topic)
  438.                 TopicScanY = 1
  439.                 EndNow = FALSE
  440.                 StartPos = INSTR(Topic(1), StartChar)
  441.                 DO WHILE NOT EndNow
  442.                     IF StartPos > 0 THEN
  443.                         TopicScanX = StartPos + 1
  444.                         LastStartPos = StartPos
  445.                         IF Direction = 1 THEN
  446.                             StartPosLine = TopicScanY
  447.                             EndNow = TRUE
  448.                         ELSE
  449.                             StartPos = INSTR(TopicScanX, Topic(TopicScanY), StartChar)
  450.                             StartPosLine = TopicScanY
  451.                         END IF
  452.                     ELSE
  453.                         IF TopicScanY < MaxTopicLines THEN
  454.                             TopicScanY = TopicScanY + 1
  455.                             TopicScanX = 1
  456.                             StartPos = INSTR(TopicScanX, Topic(TopicScanY), StartChar)
  457.                         ELSE
  458.                             EndNow = TRUE
  459.                         END IF
  460.                     END IF
  461.                 LOOP
  462.  
  463.                 ' Below only happens in Direction -1 searches
  464.                 IF LastStartPos <> StartPos AND TopicScanY <> StartLinePos THEN
  465.                     StartPos = LastStartPos
  466.                     TopicScanX = StartPos + 1
  467.                     TopicScanY = StartPosLine
  468.                 END IF
  469.             ELSE
  470.                 ' A link is currently selected.
  471.                 ' Find the next link in the topic.
  472.                 MaxTopicLines = UBOUND(Topic)
  473.                 TopicScanY = CursorPos.Y
  474.                 IF Direction = 1 THEN
  475.                     TopicScanX = CursorPos.X + 1
  476.                     TimesThrough = 0 ' TimesThrough is used so this routine can loop back to start of the topic if it doesn't find a match going forward.
  477.                     StartPos = INSTR(TopicScanX, Topic(TopicScanY), StartChar)
  478.                     DO
  479.                         StartPos = INSTR(TopicScanX, Topic(TopicScanY), StartChar)
  480.                         EndNow = FALSE
  481.                         DO WHILE NOT EndNow
  482.                             IF StartPos > 0 THEN
  483.                                 TopicScanX = StartPos + 1
  484.                                 EndNow = TRUE
  485.                             ELSE
  486.                                 IF TopicScanY < MaxTopicLines THEN
  487.                                     TopicScanY = TopicScanY + 1
  488.                                     TopicScanX = 1
  489.                                     StartPos = INSTR(TopicScanX, Topic(TopicScanY), StartChar)
  490.                                 ELSE
  491.                                     EndNow = TRUE
  492.                                     TimesThrough = TimesThrough + 1
  493.                                     TopicScanX = 1
  494.                                     TopicScanY = 1
  495.                                 END IF
  496.                             END IF
  497.                         LOOP
  498.                     LOOP UNTIL (TimesThrough = 2) OR (StartPos > 0)
  499.                 ELSE
  500.                     ' Scan backwards.
  501.                     TimesThrough = 0
  502.                     TopicScanX = 0
  503.                     StartPos = CursorPos.X - 2
  504.                     DO UNTIL EndNow OR TimesThrough = 2
  505.                         IF StartPos < 1 THEN
  506.                             EndLineNow = TRUE
  507.                         ELSE
  508.                             EndLineNow = FALSE
  509.                         END IF
  510.  
  511.                         ' See if there's any need for
  512.                         ' checking the line char by char.
  513.                         ' Small optimization.
  514.                         IF INSTR(Topic(TopicScanY), StartChar) = 0 THEN
  515.                             EndLineNow = TRUE
  516.                         END IF
  517.  
  518.                         DO UNTIL EndLineNow
  519.                             IF MID$(Topic(TopicScanY), StartPos, 1) = StartChar THEN
  520.                                 TopicScanX = StartPos + 1
  521.                                 EndLineNow = TRUE
  522.                                 EndNow = TRUE
  523.                             ELSE
  524.                                 StartPos = StartPos - 1
  525.                                 IF StartPos = 0 THEN EndLineNow = TRUE
  526.                             END IF
  527.                         LOOP
  528.  
  529.                         IF NOT EndNow THEN
  530.                             TopicScanY = TopicScanY - 1
  531.                             IF TopicScanY = 0 THEN
  532.                                 TopicScanY = MaxTopicLines
  533.                                 TimesThrough = TimesThrough + 1
  534.                             END IF
  535.                             StartPos = LEN(Topic(TopicScanY))
  536.                         END IF
  537.                     LOOP
  538.                 END IF
  539.             END IF
  540.  
  541.             IF StartPos > 0 THEN
  542.                 ' Found a topic start marker.
  543.                 ' Find the end marker.
  544.                 EndPos = INSTR(TopicScanX + 1, Topic(TopicScanY), EndChar)
  545.  
  546.                 ' Be sure that an end marker was found
  547.                 IF EndPos = 0 THEN
  548.                     MSGBOX "No topic end marker found.", 0, "Help"
  549.                     EXIT SUB
  550.                 END IF
  551.  
  552.                 TopicFound = MID$(Topic(TopicScanY), StartPos + 1, EndPos - StartPos - 1)
  553.  
  554.                 ' Now scroll the display appropriately
  555.                 ' so the link can be seen.
  556.  
  557.                 ' Is the link being displayed now?
  558.                 ' Vertically first
  559.                 IF TopicScanY < StartLine OR TopicScanY > StartLine + pctBackground.ScaleHeight - 1 THEN
  560.  
  561.                     ' The link isn't on a visible line.
  562.                     ' Scroll so the topic is visible
  563.                     ' vertically
  564.  
  565.                     IF TopicScanY > StartLine + pctBackground.ScaleHeight - 1 THEN
  566.                         StartLine = TopicScanY - pctBackground.ScaleHeight + 1
  567.                     ELSE
  568.                         StartLine = TopicScanY
  569.                     END IF
  570.                 END IF
  571.  
  572.                 ' Then horizontally
  573.                 IF TopicScanX < LeftChar OR TopicScanX >= LeftChar + ScaleWidth THEN
  574.                     ' The link isn't visible horizontally.
  575.                     ' Scroll so the topic is visible
  576.                     ' horizontally
  577.                     IF TopicScanX + LEN(TopicFound) + 1 < pctBackground.ScaleWidth THEN
  578.                         LeftChar = 1
  579.                     ELSE
  580.                         LeftChar = TopicScanX - pctBackground.ScaleWidth + LEN(TopicFound) + 1
  581.                     END IF
  582.                 END IF
  583.  
  584.                 ' Now reprint the topic
  585.                 CursorPos.Y = TopicScanY
  586.                 CursorPos.X = TopicScanX
  587.                 HelpPrintText StartLine, LeftChar
  588.             END IF
  589.  
  590.         ' Scroll using the cursor keys
  591.         CASE 39 'crsr right
  592.             IF hscHelp.Value < hscHelp.Max THEN hscHelp.Value = hscHelp.Value + 1
  593.         CASE 38 'crsr up
  594.             IF vscHelp.Value > 1 THEN vscHelp.Value = vscHelp.Value - 1
  595.         CASE 37 'crsr left
  596.             IF hscHelp.Value > 1 THEN hscHelp.Value = hscHelp.Value - 1
  597.         CASE 40 'crsr down
  598.             IF vscHelp.Value < vscHelp.Max THEN vscHelp.Value = vscHelp.Value + 1
  599.  
  600.         CASE 36 ' Home
  601.             IF Shift AND 2 THEN ' If ctrl is pressed
  602.                 vscHelp.Value = 1
  603.             ELSE
  604.                 hscHelp.Value = 1
  605.             END IF
  606.         CASE 35 ' End
  607.             IF Shift AND 2 THEN ' If ctrl is pressed
  608.                 vscHelp.Value = vscHelp.Max
  609.             ELSE
  610.                 hscHelp.Value = hscHelp.Max
  611.             END IF
  612.         CASE 33 ' PgUp
  613.             vscHelp.Value = HelpMax(vscHelp.Value - vscHelp.LargeChange, 1)
  614.         CASE 34 ' PgDn
  615.             vscHelp.Value = HelpMin(vscHelp.Value + vscHelp.LargeChange, (vscHelp.Max))
  616.     END SELECT
  617. END SUB
  618.  
  619. ' MouseUp event procedure for pctBackground.
  620. ' Looks for Help links based on the location
  621. ' of mouse clicks.  See KeyUp procedure for
  622. ' how TAB and Shift-TAB select links.
  623. '
  624. SUB pctBackground_MouseUp (Button AS INTEGER, Shift AS INTEGER, X AS SINGLE, Y AS SINGLE)
  625.     ' Find the link
  626.  
  627.     IF Y + StartLine <= UBOUND(Topic) THEN
  628.         ' Providing the user clicked somewhere
  629.         ' there is text....
  630.  
  631.         TopicLine$ = Topic(Y + StartLine)
  632.         MouseCursorPos = LeftChar + X
  633.  
  634.         ' Go forward to look for a EndChar
  635.         EndPos = INSTR(MouseCursorPos, TopicLine$, EndChar)
  636.         IF EndPos = 0 THEN
  637.             ' No EndChar on this line to the right of
  638.             ' the mouse click.
  639.             TopicFound = ""
  640.             EXIT SUB
  641.         END IF
  642.  
  643.         ' Go back and look for StartChar.
  644.         EndNow = 0
  645.         StartPos = MouseCursorPos
  646.         DO UNTIL EndNow
  647.             SELECT CASE MID$(TopicLine$, StartPos, 1)
  648.             CASE StartChar
  649.                 ' Found a topic start char.
  650.                 EndNow = -1
  651.             CASE EndChar
  652.                 ' Found a link EndChar.
  653.                 ' Unless this is the char under
  654.                 ' the mouse, cancel the seach.
  655.                 ' Means the mouse is in between
  656.                 ' two Help links.
  657.                 IF StartPos <> MouseCursorPos THEN
  658.                     TopicFound = ""
  659.                     EXIT SUB
  660.                 ELSE
  661.                     ' Just back up and keep on looking
  662.                     StartPos = StartPos - 1
  663.                     IF StartPos = 0 THEN EndNow = -1
  664.                 END IF
  665.             CASE ELSE
  666.                 ' Back up.  Stop if reach start of line.
  667.                 StartPos = StartPos - 1
  668.                 IF StartPos = 0 THEN EndNow = -1
  669.             END SELECT
  670.         LOOP
  671.  
  672.         IF StartPos = 0 THEN
  673.             TopicFound = ""
  674.             EXIT SUB
  675.         END IF
  676.  
  677.         ' Sets the Common Shared TopicFound variable.
  678.         TopicFound = MID$(TopicLine$, StartPos + 1, EndPos - StartPos - 1)
  679.  
  680.         ' Jump to that topic.
  681.         HelpShowTopic TopicFound
  682.     END IF
  683. END SUB
  684.  
  685. ' Change event procedure for the vertical scroll bar.
  686. ' Scrolls help topic text.
  687. SUB vscHelp_Change ()
  688.     ' Call the HelpPrintText routine using the new
  689.     ' vertical scroll bar value.
  690.     HelpPrintText (vscHelp.Value), LeftChar
  691.  
  692.     ' Refresh the form and ensure pctBackground
  693.     ' has the focus.
  694.     pctBackground.REFRESH
  695.     pctBackground.SETFOCUS
  696. END SUB
  697.  
  698.